package org.nimi317.web_gis.form.get;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.nimi317.web_gis.entity.Station;
import org.nimi317.web_gis.entity.StationQuality;
import org.nimi317.web_gis.utils.QualityUtils;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * @author thunderobot
 */
@Data
@AllArgsConstructor
public class StationQualityWeb {
    private Integer ProvinceId;
    private Integer CityCode;
    private LocalDateTime TimePoint;
    private String TimePointStr;
    private String Area;
    private String PositionName;
    private String Quality;
    private String PrimaryPollutant;
    private String QualityLevel;
    private String StationCode;
    private String CO;
    private String CO_24h;
    private String Latitude;
    private String Longitude;
    private String Measure;
    private String NO2;
    private String NO2_24h;
    private String O3;
    private String O3_24h;
    private String O3_8h;
    private String O3_8h_24h;
    private String PM10;
    private String PM10_24h;
    private String PM2_5;
    private String PM2_5_24h;
    private String SO2;
    private String SO2_24h;
    private String AQI;
    private Integer COLevel;
    private Integer NO2Level;
    private Integer O3Level;
    private Integer O3_8hLevel;
    private Integer PM10Level;
    private Integer PM2_5Level;
    private Integer SO2Level;
    private String Unheathful;
    private String IsPublish;
    private Integer OrderId;
    private String NO;
    private String NO_24h;
    private String NOx;
    private String NOx_24h;

    public StationQuality toStationQuality() {
        StationQuality quality = new StationQuality();
        quality.setStationCode(this.getStationCode());
        quality.setCo(this.getCO());
        quality.setAqi(this.getAQI());
        quality.setO3(this.getO3());
        quality.setPm10(this.getPM10());
        quality.setPm25(this.getPM2_5());
        quality.setNo2(this.getNO2());
        quality.setSo2(this.getSO2());
        quality.setO3H(this.getO3_8h());
        quality.setPm25H(this.getPM2_5_24h());
        quality.setPm10H(this.getPM10_24h());
        quality.setSo2H(this.getSO2_24h());
        quality.setTimestamp(this.getTimePoint());
        quality.setCoLevel(this.getCOLevel());
        quality.setNo2Level(this.getNO2Level());
        quality.setO3Level(this.getO3Level());
        quality.setPm10Level(this.getPM10Level());
        quality.setSo2Level(this.getSO2Level());
        quality.setPm25Level(this.getPM2_5Level());
        new QualityUtils<>(quality).exeLevel();
        return quality;
    }

    public Station toStation(Integer cityCode) {
        Station station = new Station();
        station.setStationCode(this.getStationCode());
        station.setPositionName(this.getPositionName());
        station.setLongitude(this.getLongitude());
        station.setLatitude(this.getLatitude());
        station.setCityCode(cityCode);
        station.setCreateTime(LocalDate.now());
        station.setStatus(true);
        return station;
    }
}
